package com.example.wxytest.demos.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.wxytest.demos.Student;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface StudentMapper extends BaseMapper<Student> {

    @Select("SELECT * FROM student")
    List<Student> findAll();

    @Select("SELECT * FROM student WHERE id = #{id}")
    Student findById(@Param("id") Integer id);

    @Insert("INSERT INTO student(student_id, name, class, telephone, qq) VALUES(#{studentId}, #{name}, #{classStr}, #{telephone}, #{qq})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void add(Student student);

    @Update("UPDATE student SET student_id=#{studentId}, name=#{name}, class=#{classStr}, telephone=#{telephone}, qq=#{qq} WHERE id=#{id}")
    void update(Student student);

    @Delete("DELETE FROM student WHERE id=#{id}")
    void deleteById(@Param("id") Integer id);
}